package com.sean.framework.databases;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.sean.common.databases.SQLUtil;
import com.sean.framework.pojo.User;

public class AppDBHelper extends SQLiteOpenHelper {

	public static final String DB_NAME = "database.db";
	public static final int VERSION = 1;
	
	public static AppDBHelper mDBHelper;
	
	private AppDBHelper(Context context) {
		super(context, DB_NAME, null, VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(SQLUtil.getCreatTableSQL(User.class));
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		this.onCreate(db);
	}
	
	public static AppDBHelper getInstance(Context context) {
		if(mDBHelper == null) {
			mDBHelper = new AppDBHelper(context);
		}
		return mDBHelper;
	}
	
	public static AppDBHelper getNewInstance(Context context) {
		return new AppDBHelper(context);
	}

}
